package com.myhome.money.spring.lifecycle;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author Rod
 */
public class BeanLifeCycle {

    public static void main(String[] args) {
        System.out.println(".......spring容器初始化开始......");

        ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:beans.xml");
        System.out.println("-----------------------------------------------容器初始化成功");

        //得到Preson，并使用
        Person person = ctx.getBean("person", Person.class);
        System.out.println(person);

        System.out.println("现在开始关闭容器！");
        ((ClassPathXmlApplicationContext) ctx).registerShutdownHook();


    }
}
